home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Networking / SNMP / SNMP Development / MacSNMP Developer 1.0.2 / SNMP Interfaces / SNMP.h next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  5.0 KB  |  214 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SNMP.h
  3.  
  4.     Contains:    Constants, typedefs, etc for SNMP
  5.     
  6.     Copyright:    © 1991-1992 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9. /***********************************************************
  10.     Copyright 1988, 1989 by Carnegie Mellon University
  11.  
  12.                       All Rights Reserved
  13.  
  14. ******************************************************************/
  15.  
  16. #ifndef __SNMP__
  17. #define __SNMP__
  18.  
  19.  
  20. /**********************************************************************
  21. *    Macros
  22. **********************************************************************/
  23.  
  24. #define kDynamicArray    1                // array could have more that one item
  25.  
  26. /**********************************************************************
  27. * SNMP Variable types
  28. **********************************************************************/
  29. #include <SNMPVarTypes.h>
  30.  
  31. /**********************************************************************
  32. *    Other Constants
  33. **********************************************************************/
  34. // the    currently supported version of snmp
  35. #define kCurrentSNMPVersion        0
  36.  
  37. #define     kMaxIDCount        25        // max number of sub ids in an object id
  38.  
  39. #define        kMaxCommunities 16        // max number of communites
  40. #define     kMyPrecedence    128
  41. #define        kMaxNameLen        32        // max length for agent, group, and variable names
  42.  
  43. /**********************************************************************
  44. *    Typedefs
  45. **********************************************************************/
  46.  
  47. typedef unsigned long ASNTagType;
  48.  
  49. // SMI Access Modes
  50.  
  51. enum {
  52.     smiReadOnly = 0, 
  53.     smiWriteOnly, 
  54.     smiReadWrite, 
  55.     smiNotAccessible
  56. };
  57.  
  58. typedef short     SMIAccess;
  59.  
  60. // SNMP Manager specific typedefs
  61.  
  62. typedef unsigned long SNMPRefNum;        // unique ID for SNMP Manger clients
  63.  
  64. //    Error codes for SNMP Manager
  65.  
  66. #define        ErrorCodeBase        -25500
  67.  
  68. enum {
  69.     snmpNoError         = 0,
  70.     snmpBadID             = ErrorCodeBase - 1,
  71.     snmpNoMoreMIB         = ErrorCodeBase - 2,
  72.     snmpEndOfColumn     = ErrorCodeBase - 3,
  73.     snmpBufTooSmall     = ErrorCodeBase - 4,
  74.     snmpDuplicateVar     = ErrorCodeBase - 5,
  75.     snmpDupPrecedence     = ErrorCodeBase - 6,
  76.     snmpNoVarFound         = ErrorCodeBase - 7,
  77.     snmpMemError         = ErrorCodeBase - 8,
  78.     snmpGenError         = ErrorCodeBase - 9,
  79.     snmpBadParm         = ErrorCodeBase - 10,
  80.     snmpMalformedID     = ErrorCodeBase - 11,
  81.     snmpBTreeError         = ErrorCodeBase - 12,
  82.     snmpNotFound         = ErrorCodeBase - 13,
  83.     snmpDupAgentName     = ErrorCodeBase - 14,
  84.     snmpDupGroupID         = ErrorCodeBase - 15,
  85.     snmpBadValue         = ErrorCodeBase - 16,
  86.     snmpEnd                = ErrorCodeBase - 32
  87. };
  88.  
  89. typedef short     SNMPError;
  90.  
  91. //
  92. // interface descriptions and locations
  93. //
  94. // if description is for a slot, location is the slot number
  95. // if description is for Enet0, location is ignored
  96. // if description is for localtalk, location is kIFLoc_LTalkPortB or kIFLoc_LTalkPortA
  97. //
  98. // if the index is known then kIFunknownIndex is returned
  99. //
  100.  
  101. #define kIFunknownIndex 0xffffffff
  102.  
  103. #define kIFdescr_Slot     0
  104. #define kIFdescr_Enet0  -1
  105. #define kIFdescr_LTalk    -2
  106.  
  107. #define kIFLoc_LTalkPortB 1
  108. #define kIFLoc_LTalkPortA 2
  109.  
  110.  
  111. //    SNMP generic trap codes
  112.  
  113. enum{
  114.     snmpColdStart = 0, 
  115.     snmpWarmStart, 
  116.     snmpLinkDown, 
  117.     snmpLinkUp, 
  118.     snmpAuthenticationFailure,
  119.     snmpEGPNeighborLoss, 
  120.     snmpEnterpriseSpecific
  121. };
  122.  
  123. typedef short SNMPTrapCode;
  124.  
  125. //    for Set Variable Routines
  126.  
  127. enum SetStage {
  128.     setAllocate = 0,
  129.     setConsistency,
  130.     setChange,
  131.     setRevert
  132. };
  133.  
  134. typedef enum SetStage SetStage;
  135.  
  136.  
  137. //    Explicit unique name for a MIB variable (object identifier)
  138.  
  139. struct ObjectID {
  140.     unsigned short    count;                    // count of ids 
  141.     unsigned long    id[kDynamicArray];        // ordered array of ids
  142. };
  143.  
  144. typedef struct ObjectID        ObjectID;
  145. typedef ObjectID*            ObjectIDPtr;
  146.  
  147.  
  148. //  A linked list of object identifiers
  149.  
  150. struct ObjectIDList {
  151.     struct ObjectIDList*    nextObjID;    // NULL at end of list
  152.     ObjectID                anObjID;    // an object identifier
  153. };
  154.  
  155. typedef    struct ObjectIDList ObjectIDList;
  156. typedef    ObjectIDList* ObjectIDListPtr;
  157.  
  158.     
  159. //    MIB variable data.
  160.  
  161. struct MIBVariable {
  162.     ASNTagType         type;            // ASN.1 Type of this MIB variable
  163.     short            dataSize;        // size of data buffer
  164.     char*            dataPtr;        // pointer to data buffer
  165.     ObjectIDPtr        idPtr;            // explicit unqiue identifier
  166. };
  167.     
  168. typedef struct MIBVariable    MIBVariable;
  169. typedef MIBVariable*        MIBVariablePtr;
  170.  
  171.  
  172. // A linked list of MIB variables
  173.  
  174. struct MIBlet {
  175.     struct MIBlet*    nextMIBlet;        // NULL for last variable
  176.     MIBVariable        mibVar;            // a MIB Variable
  177. };
  178.     
  179. typedef struct MIBlet    MIBlet;
  180. typedef MIBlet*            MIBletPtr;
  181.  
  182.  
  183. // for variable sets and gets
  184.  
  185. struct VarBuf{
  186.     unsigned int    maxlen;    
  187.     unsigned int    len;
  188.     char*            buf;
  189. };
  190.  
  191. typedef struct VarBuf    VarBuf;
  192. typedef VarBuf*            VarBufPtr;
  193.  
  194.  
  195. /**********************************************************************
  196. **    SNMP Transport specific types
  197. **********************************************************************/
  198. typedef long    TransportTag;    // unique to the Transport across boots
  199. typedef void*    TIAddressPtr;    // Transport Independent (opaque) network address
  200.  
  201. // Raw SNMP packets
  202. // last PacketPiece has length zero and no pointer (à la Write Data Structure) 
  203.  
  204. struct PacketPiece {
  205.     short    length;            
  206.     char*    dataPtr;        
  207. };
  208.     
  209. typedef    struct PacketPiece    PacketPiece;
  210. typedef    PacketPiece*        PacketPiecePtr;
  211.  
  212.  
  213. #endif /* __SNMP__ */
  214.